package com.topone.pos.startup;

import com.topone.pos.commons.utils.SessionUtil;
import com.topone.pos.commons.*;
import com.topone.pos.data.UsrMstr;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.SessionFactory;


/**
 * <p>Title: TopOne POS application</p>
 * <p>Description: Startup main frame.</p>
 * <p>Copyright: Copyright (C) 2010 TopOne</p>
 * @author Joe Chu
 * @version 1.0
 */

public class StartPOS{

  
    public StartPOS(String args[]){

        Configuration cfg = new Configuration();
        cfg.addClass(com.topone.pos.data.UsrMstr.class);
        cfg.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLDialect");
        cfg.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
        cfg.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/test");
        cfg.setProperty("hibernate.connection.username", "root");
        cfg.setProperty("hibernate.current_session_context_class", "thread");
        cfg.setProperty("hibernate.connection.pool_size", "1");
        cfg.setProperty("hibernate.show_sql", "true");
        cfg.setProperty("hibernate.hbm2ddl.auto", "create");
        SessionFactory sessons = cfg.buildSessionFactory();
        Session session = sessons.openSession();
        
/*
        Session session = SessionUtil.getSessionFactory().getCurrentSession();
  */
        session.beginTransaction();
        UsrMstr uservo = new UsrMstr();
        uservo.setUserID("abc1");
        session.save(uservo);
        session.getTransaction().commit();



    /*Client Settings*/ 
   /*
    ClientDefine clientdefine = new ClientDefine();
    clientdefine.setClient();        
*/
    /*Local Appliction Config*/
/*
    AppConfig o_Config = new AppConfig(args);
    o_Config.load();

    try{
        Session c_session = AppViewConnection.createSession(o_Config);            
    }catch(BasicException e){
        Message.Show(e);
        return;
    }
     */
    /*Login Frame*/
    /**
        LoginFrame o_LoginFrame = new LoginFrame();
    o_LoginFrame.setVisible(true);
   */

    }

    /**
    *<p>Description:Get local config and show login form.</p>
    */
    public static void main (String args[]) {
        new StartPOS(args);
    }

}


